
#数据处理部分之前的代码，保持不变
import os
import random
import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph.nn import Conv2D, Pool2D, FC
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image

import gzip
import json
# 多层全连接神经网络实现
class MNIST(fluid.dygraph.Layer):
    def __init__(self, name_scope):
        super(MNIST, self).__init__(name_scope)
        name_scope = self.full_name()
        # 定义两层全连接隐含层，输出维度是10，激活函数为sigmoid
        self.fc1 = FC(name_scope, size=10, act='sigmoid') # 隐含层节点为10，可根据任务调整
        self.fc2 = FC(name_scope, size=10, act='sigmoid')
        # 定义一层全连接输出层，输出维度是1，不使用激活函数
        self.fc3 = FC(name_scope, size=1, act=None)
    
    # 定义网络的前向计算
    def forward(self, inputs, label=None):
        outputs1 = self.fc1(inputs)
        outputs2 = self.fc2(outputs1)
        outputs_final = self.fc3(outputs2)
        return outputs_final